/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package entreprise;

import java.sql.SQLException;
import java.util.Date;
import java.util.List;
import mapping.DBSession;

/**
 *
 * @author Quoc-Khai
 */
public class SessionService {
    public boolean createSession(int sessionID, Date sessionDate, String doctor, String require, String diagnostic) throws SQLException{
        DBSession dbSession = new DBSession();
        Session iSession = new Session();
        iSession = dbSession.getSession(sessionID);
        if (iSession.getSessionID().length() <= 0) {
            iSession.setSessionDate(sessionDate);
            iSession.setDoctor(doctor);
            iSession.setRequire(require);
            iSession.setDiagnostic(diagnostic);
            
            dbSession.createSession(iSession);
            return true;
        }
        
        System.out.println("Session existe!");
        return false;
    }
    public boolean deleteSession(int sessionID) throws SQLException{
        DBSession dbSession = new DBSession();
        Session iSession = new Session();
        iSession = dbSession.getSession(sessionID);
        if (iSession.getSessionID().length() > 0) {
            dbSession.deleteSession(sessionID);
            return true;
        }
        
        System.out.println("Session not existe!");
        return false;
    }
    public boolean updateSession(int sessionID, Date sessionDate, String doctor, String require, String diagnostic) throws SQLException{
        DBSession dbSession = new DBSession();
        Session iSession = new Session();
        iSession = dbSession.getSession(sessionID);
        if (iSession.getSessionID().length() > 0) {
            iSession.setSessionID(String.valueOf(sessionID));
            iSession.setSessionDate(sessionDate);
            iSession.setDoctor(doctor);
            iSession.setRequire(require);
            iSession.setDiagnostic(diagnostic);
            
            dbSession.updateSession(iSession);
            return true;
        }
        
        System.out.println("Session not existe!");
        return false;
    }
    public List<Session> findSessions(String serviceName){
        List<Session> sessions=null;
        return sessions;
    }
}
